<?php
/*
 * TinyMCE wysiwyg editor library object
 */
/*
 * TinyMCE types defines
 */
define("_TINYMCE_SIMPLE",0);
define("_TINYMCE_ADVANCED",1);
define("_TINYMCE_FULL",2);
class tinymce extends library {
	private $current = null;
	private $textareas = array();
	public function init(){

	}
	# setting up all files vs data, NOTE: it doesn't work in framework mode
	public function set($type=null,$textareas=null){
		# envinroment checking
		if( !$this->api->isloaded("base")){
			return $this->api->error("LIB_TINYMCE","Cannot work without kernel object 'base'");
		}
		switch($type){
			case _TINYMCE_SIMPLE: $type="simple"; break;
			case _TINYMCE_ADVANCED: $type="advanced"; break;
			case _TINYMCE_FULL: $type="full"; break;
		}
		if( $this->api->get("liburl")==null)
		$url = $this->api->url()."lib/";
		else 
		$url = $this->api->parseasurl($this->api->get("liburl"));
		# global tinymce object link
		$linktiny = $url."tinymce/jscripts/tiny_mce/tiny_mce.js";
		# 
		$link = $url."tinymce/".$type.".js";
		# 
		$this->api->base->addjs($linktiny);
		$this->api->base->addjs($link);
		return true;
	}
	# returns link to tinymce basic html object
	public function getlink(){
		if( $this->api->get("liburl")==null)
		$url = $this->api->url()."lib/";
		else 
		$url = $this->api->parseasurl($this->api->get("liburl"));		
		return $url."tinymce/jscripts/tiny_mce/tiny_mce.js";
	}
}
?>